* Stata do-file, Robustness tests for Chapter 4, Mark R. Beissinger, 
*    The Revolutionary City  
version 14
clear all
set more off
log using Robustnesstestfiles\Logfiles\robustnesstestschapter4.log, replace
* ============================================================================
* ROBUSTNESS CHECKS FOR STATISTICAL RESULTS APPEARING IN CHAPTER 4
* STATA  
* Robustness checks for results reported in Chapter 4  
* Author: Mark R. Beissinger  
* Date:  January 2022  
* Princeton, NJ 
* =============================================================================
* BEFORE RUNNING, YOU MUST SET THE DEFAULT PATH FOR WHERE THE DATA
*   FILES RESIDE
* ============================================================================
* The following datafiles are used in this file:
*   Dataset of revolutionary episodes--revolutionaryeps.dta
*   Multiple imputation dataset for revolutionary episodes (regime variables)--
*		revolutionaryepsmireg.dta
*	Multiple imputation dataset for revolutionary episodes (opposition variables)--
*		revolutionaryepsmiopp.dta
*	Multiple imputation dataset for revolutionary episodes (combined model)--
*		revolutionaryepsmicomb.dta
* =============================================================================
* Before running, you must download the following packages for STATA:
* 	checkrob from http://fmwww.bc.edu/RePEc/bocode/c
*	collin from https://stats.oarc.ucla.edu/stata/ado/analysis/
* 	eststo and esttab from http://www.stata-journal.com/software/sj7-2
* =============================================================================
* The following output is produced by these robustness tests:
*		Robustnesstestfiles\Logfiles\robustnesstestschapter4.log
*
*	The following graphs are produced by these robustness tests:
*		Robustnesstestfiles\Logfiles\robch4tab4_1_scat1.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_1_scat2.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_1_scat3.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_1_scat4.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_1_scat5.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_1_scat6.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_1_scat7.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_1_scat8.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_1_scat9.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_2_scat1.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_2_scat2.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_2_scat3.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_2_scat4.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_2_scat5.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_2_scat6.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_2_scat7.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_2_scat8.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_2_scat9.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_3_scat1.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_3_scat2.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_3_scat3.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_3_scat4.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_3_scat5.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_3_scat6.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_3_scat7.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_3_scat8.pdf
*		Robustnesstestfiles\Logfiles\robch4tab4_3_scat9.pdf
*
*	These files have been combined with the logfile for the chapter into a 
*		single output file, located in the Robustnesstestfiles\Outputfiles
*		folder 
*	In addition, the reworked output from the checkrob procedure run in this
*	   chapter can be viewed in the Excel file checkrob.results.chapter4.xlsx,
*		also located in the Robustnesstestfiles\Outputfiles folder		
* =============================================================================

clear
use revolutionaryeps.dta
quietly: logit success c.newpolitymin1##c.newpolitymin1 newincumbpowerdur newgdppcthl newlnoill i.civilwar##c.newmilexpsold10tile if startyear>1899 & colony==0, or nolog
generate sample=e(sample)

* =============================================================
* ROBUSTNESS TESTS FOR MODELS 6 & 9 IN TABLE 4.1--REGIME MODEL
* =============================================================

* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Testing robustness of the specification to inclusion or exclusion of variables
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* ************
* PLEASE READ
* ************
* The checkrob procedure checks all possible combinations of variables and tests 
*   if signs are stable and whether z-statistics for Beta/S.E. of Beta are >1.96 
*		(i.e., .05 level of significance) or >1.65 and <1.96 (i.e., .10 level of 
*		significance).
* All z-statistics were calculated in Excel from the comma-separated tables 
*		produced from the output of checkrob.      
* BEWARE: There is a glitch in the checkrob procedure involving quadratic 
*		specifications. In the tables produced by the procedure, the results for
*		the first variable of a quadratic specification sometimes falsely 
*       include results from the squared variable. ONE MUST VISUALLY INSPECT 
*		AND, IF PRESENT, HAND-CORRECT.
* I HAVE PROVIDED AN EXCEL TABLE WITH RESULTS OF THE TEST BELOW THAT CORRECTS
*	FOR THE ABOVE PROBLEM AND CALCULATES THE Z-SCORES (See the Excel file 
*	checkrob.results.chapter4.xlsx, which contains all results of all checkrob
*	tests in this chapter).
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* THE FOLLOWING COMMANDS WERE USED TO CREATE THE EXCEL TABLE.
* DO NOT RUN THESE COMMANDS UNLESS YOU INTEND TO RECONFIGURE THE OUTPUT
*	TO CORRECT FOR THE ABOVE GLITCH AND TO CALCULATE THE Z-SCORES BY HAND.
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Recreate common sample for complete-case sample (Model 9)
*   quietly:  logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newincumbage newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp if startyear>1899, or
*   generate sample=e(sample)
* Run checkrob command
*   checkrob 2 6 ch4tab1mod9.txt:  logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp if startyear>1899 & sample==1, or
* RESULTS:
* 	Given that the variables for newpolitymin1 and newpolitymin1sq must be together, there are 32 possible combinations
*		(Do note, however, that civilwar, newilexpsold10tile, and newcivxmilexp form an interaction)
*	--newpolitymin1 and newpolitymin1sq are significant at .05 level or better in 100% of specifications, with no sign changes
*   --newincumbpowerdur is significant at .05 level in 100% of specifications, with no sign changes
*	--newgdppcthl is significant at the .05 level in 37.5%, significant at the .10 level in 6.3%, and insignificant in 56.3% of specifications; 
*		sign changes:  positive in 53.1% (almost all of which are statistically insignificant, with two significant at the .10 level) and 
*		negative in 46.9% (and in most cases, statistically significant at the .05 level)
*		newgdppcthl appears interact with some of the other variables in the specification--particularly newlnoill and newmilexpsold10tile
*	--newlnoill is significant at the .05 level in 93.8% of specifications and at the .10 level in 6.3% of specifications, with no sign changes (consistently negative)
*	--when not in interaction, newmilexpsold10tile is always significant at the .05 level and positive, no sign changes
*	--when not in interaction, civilwar is always statistically significant and negative;
* 	--in the interaction civilwar x newmilexpsold10tile (8 specifications in which they appear together--all others are ignored):
*		newmilexpsold10tile is always significant at the .05 level and positive , no sign changes
*		civilwar in the interaction is never statistically significant, but consistently negative
*		newcivxmilexp is consistently negative and statistically significant at the .10 level for half of the specifications of interactions and insignficant in 50 percent

* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Bootstrapped standard errors--1000 replications--complete-case sample
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp if startyear>1899 & sample==1, or nolog vce(bootstrap, bca seed(1234) rep(1000))
estat bootstrap, all
*  Result:  no changes in signs or patterns of significance except that
*			  interaction variable newcivxmilexp turns insignificant

* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Bootstrapping multiple imputation estimation--regime model
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* using 10 imputations, 100 bootstraps (20 imputations takes a very long time)
* WARNING: THIS TEST CAN TAKE 40 MINUTES TO COMPLETE
use revolutionaryeps.dta, clear
drop if colony==1
program define myboot, rclass
   mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp = success civilwar, add(10) rseed(1234) force
   mi estimate, eform: logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp, or
   return scalar b_npo1 = el(e(b_mi),1,1)
   return scalar b_npsq = el(e(b_mi),1,2)
   return scalar b_newi = el(e(b_mi),1,3)
   return scalar b_newg = el(e(b_mi),1,4)
   return scalar b_newo = el(e(b_mi),1,5)
   return scalar b_newm = el(e(b_mi),1,6)
   return scalar b_civw = el(e(b_mi),1,7)
   return scalar b_cixm = el(e(b_mi),1,8)
   return scalar b_int  = el(e(b_mi),1,9)
end
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newincumbpowerdur newincumbage newgdppcthl newlnoill newmilexpsold10tile newcivxmilexp
set seed 1234
bootstrap b_newpolitymin1=r(b_npo1) b_newpolitymin1sq=r(b_npsq) b_newincumbpowerdur=r(b_newi) b_newgdppcthl=r(b_newg) b_newlnoill=r(b_newo) b_newmilexpsold10tile=r(b_newm) b_civilwar=r(b_civw) b_newcivxmilexp=r(b_cixm) intercept=r(b_int), reps(100) eform : myboot 
* Displaying exponentiated form
bootstrap, eform
clear programs
*  Result:  no changes in signs or patterns of significance

* ++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Testing for multicollinearity in complete case sample 
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++
use revolutionaryeps.dta, clear
quietly: logit success c.newpolitymin1##c.newpolitymin1 newincumbpowerdur newgdppcthl newlnoill i.civilwar##c.newmilexpsold10tile if startyear>1899 & colony==0, or nolog
generate sample=e(sample)
collin newpolitymin1  newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp if startyear>1899 & sample==1
*	RESULT:  VIF all within acceptable range (VIF>5 is cause of concern, VIF>10 indicates significant problem)

* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Visual inspection of potential outliers, complete case model
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
quietly: logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp if startyear>1899 & sample==1, or nolog
predict pr , pr
predict stdres, rstand
predict dev, dev
predict hat, hat
predict dx2, dx2
predict dd, dd
* Standardized Pearson residuals by predicted probability
scatter stdres pr, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_1_scat1.pdf, replace
* 	RESULT: Identified revid 269 (1990 Mongolian Revolution) as potential outlier
*		Identified revid 47 (Spanish Civil War) as potential outlier
*		Identified revid 243 (First Chechen War)
*		Identified revid 399 (Burkinabe Uprising 2014)
* Standardized Pearson residuals by revid
scatter stdres revid, mlab(revi)  yline(0) 
graph export Robustnesstestfiles\Logfiles\robch4tab4_1_scat2.pdf, replace
* 	RESULT: Identified revid 269 (1990 Mongolian Revolution) as potential outlier
*		Identified revid 47 (Spanish Civil War) as potential outlier
*		Identified revid 243 (First Chechen War)
* Deviance residual by revid
scatter dev revid, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_1_scat3.pdf, replace
* 	RESULT: Identified revid 269 (1990 Mongolian Revolution) as potential outlier
*		Identified revid 47 (Spanish Civil War) as potential outlier
*		Identified revid 243 (First Chechen War)
* Leverage by predicted probability
scatter hat pr, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_1_scat4.pdf, replace
* 	RESULT: Identified revid 111 (First Intifada)
*		Identified revid 399 (Burkinabe Uprising 2014)
*		Identified revid 135 (Second Intifada)
*		Identified revid 338 (2006 Hungarian Protests)
*		Identified revid 399 (Burkinabe Uprising 2014)
* Leverage by revid (with cutoff point of 3 * the mean of leverage)--easier to see
mean hat
matrix coefs = e(b)
local hatmean = 3 * (coefs[1,1])
scatter hat revid, mlab(revid) yline(0) yline(`hatmean')
graph export Robustnesstestfiles\Logfiles\robch4tab4_1_scat5.pdf, replace
* 	RESULT: Identified revid 111 (First Intifada)
*		Identified revid 117 (East German Revolution)
*		Identified revid 152 (Armenian colored revolution attempt)
* Difference of chi-squares
scatter dx2 revid, mlab(revid)
graph export Robustnesstestfiles\Logfiles\robch4tab4_1_scat6.pdf, replace
*	RESULT: Identified revid 243 (First Chechen War)
*		Identified revid 47 (Spanish Civil War) as potential outlier
* Difference of deviances
scatter dd revid, mlab(revid)
graph export Robustnesstestfiles\Logfiles\robch4tab4_1_scat7.pdf, replace
*	RESULT: Identified revid 243 (First Chechen War)
*		Identified revid 47 (Spanish Civil War) out potential outlier
* Drop predictions
drop pr stdres dev hat dx2 dd

* Testing the effect of dropping potential outliers on results in Model 9
eststo: quietly: logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp if startyear>1899 & sample==1, or nolog
eststo: quietly: logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp if startyear>1899 & sample==1 & revid!=269 & revid!=47 & revid!=243 & revid!=399 & revid!=111 & revid!=135 & revid!=338 & revid!=117 & revid!=152, or nolog
esttab , star (+ 0.10 * 0.05 ** 0.01 *** 0.001) mtitles(All_n No_outl)
* 	RESULT:  No change in signs and patterns of significance, but newgdppcthl and 
* 		the newcivxmilexp interaction becomes significant at the .05 level
eststo clear

* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Visual inspection of potential outliers, multiple imputation model
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
use revolutionaryepsmireg.dta, clear
quietly: mi estimate, post dots eform saving(miest, replace): logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp if startyear>1899
mi predict xb using miest , xb
mi predict stdp using miest, stdp
scatter  stdp xb, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_1_scat8.pdf, replace
*	RESULT: Identified revid 243 (First Chechen War)
*			Identified revid 290 (First Sudanese Civil War) as potential outlier
*			Identified revid 331 (Congo Crisis) as potential outlier
*			Identified revid 301 (2007 Guinean General Strike) as potential outlier
*			Identified revid 259 (228 Uprising) as potential outlier
*			Identified revid 298 (Black Friday in Maldives) as potential outlier
scatter  stdp revid, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_1_scat9.pdf, replace
*			Identified revid 383 (Christmas Uprising) as potential outlier
* Drop predictions
drop xb stdp
* Testing the effect of dropping potential outliers on results in Model 6
eststo: quietly: mi estimate, post dots eform saving(miest, replace): logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp if startyear>1899, or
eststo: quietly: mi estimate, post dots eform saving(miest, replace): logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp if startyear>1899 & revid~=290 & revid~=331 & revid~=301 & revid~=259 & revid~=298 & revid~=383, or
esttab , star (+ 0.10 * 0.05 ** 0.01 *** 0.001) mtitles(All_n No_outl) 
* 	RESULT:  No changes in signs and patterns of significance
eststo clear

* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Linktest for omitted variable bias--complete case sample
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
use revolutionaryeps.dta, clear
quietly: logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp if startyear > 1899 & colony==0, or nolog
linktest , nolog
* 	RESULT:  passes, _hatsq is not statistically significant


* +++++++++++++++++++++++++++++++++++++++++++
* ROBUSTNESS TESTS FOR MODEL 7 IN TABLE 4.2
* +++++++++++++++++++++++++++++++++++++++++++

* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Checkrob procedure testing effect of dropping variables from specification
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* checkrob procedure checks all possible combinations of variables
* Testing if signs are stable and z-statistics for Beta/S.E. of Beta are >1.96 (i.e., .05 level of significance)
*   z-statistics were calculated in Excel (as comma-separated tables) from the output produced by checkrob 
*      .10 level of significance>1.65 and <1.96
* BEWARE: there is sometimes a glitch in the checkrob procedure
*    In the tables produced, the results for the first variable of a quadratic specification sometimes falsely 
*       include some results from the squared variable    
*    ONE MUST VISUALLY INSPECT AND, IF PRESENT, HAND-CORRECT AND RECALCULATE RESULTS FOR THOSE VARIABLES
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* I HAVE PROVIDED AN EXCEL TABLE WITH RESULTS OF THE TEST BELOW, CORRECTED FOR THE ABOVE PROBLEMS
* 	SEE FILE checkrob.results.chapter4.xlsx
* THE FOLLOWING COMMANDS WERE USED TO CREATE THE TABLE
*	(DO NOT RUN UNLESS YOU INTEND TO RECONFIGURE THE OUTPUT BY HAND)
* Recreate common sample for complete-case sample (Model 9)
*   quietly:  logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newincumbage newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp if startyear>1899, or
*   generate sample=e(sample)
* clear
* use revolutionaryepsmiopp.dta
* checkrob procedure using Model 6
* Run checkrob
* checkrob 0 6 ch4tab2mod7.txt: logit success lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch if startyear>1899, or
* RESULTS
* * RESULTS:
* 	Given that urbandum, deathtile10, and urbxdeathtile10 are in an interaction, the urbxdeathtile10 variable cannot appear alone
*		--lnparticnum is significant at the .05 level or better, with no sign changes, for all specification
*		--urbandum generally is statistically significant at the .05 level when it is in interaction with deathtile10, with no sign changes,
*				but does not hold up on its own
*		--deathtile10 is generally statistically significant at the .05 level when it is in interaction with urbandum, with no sign changes,
*				but does not hold up on its own
*		--the interaction term urbxdeathtile10 is always significant when the other terms in the interaction are included
*	democrat is significant in all specifications, with no sign changes
*	antimonarch is generally significant when democrat is included, with no sign changes (but is not significant on its own)

* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Bootstrapped standard errors--complete case sample--opposition model
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
use revolutionaryepsmiopp.dta, clear
logit success lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch if startyear>1899, or nolog vce(bootstrap, bca seed(1234) rep(1000)) iterate(15)
estat bootstrap, all
*  Result:  all variables significant at the .05 level or better, with exception of antimonarch, which is significant at the .10 level. 

* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Bootstrapping multiple imputation estimation--opposition model
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* using 10 imputations, 200 bootstraps (20 imputations takes a very long time)
use revolutionaryeps.dta
drop if startyear<1900
program define myboot, rclass
   mi impute chained (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 = success urbandum democrat antimonarch, add(10) rseed(1234) force
   mi estimate, eform: logit success lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch, or
   return scalar b_lnp = el(e(b_mi),1,1)
   return scalar b_urb = el(e(b_mi),1,2)
   return scalar b_d10 = el(e(b_mi),1,3)
   return scalar b_uxd = el(e(b_mi),1,4)
   return scalar b_dem = el(e(b_mi),1,5)
   return scalar b_mon = el(e(b_mi),1,6)
   return scalar b_int  = el(e(b_mi),1,7)
end
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed lnparticnum deathtile10 urbxdeathtile10
set seed 1234
bootstrap b_lnparticnum=r(b_lnp) b_urbandum=r(b_urb) b_deathtile10=r(b_d10) b_urbxdeathtile10=r(b_uxd) b_democrat=r(b_dem) b_antimonarch=r(b_mon) intercept=r(b_int), reps(100): myboot 
* Displaying exponentiated form
bootstrap, eform
clear programs
*  Result:  all variables significant at the .05 level or better, with exception of antimonarch, which is significant at the .10 level. 

* ++++++++++++++++++++++++++++++++++
* Testing for multicollinearity
* ++++++++++++++++++++++++++++++++++
use revolutionaryepsmiopp.dta, clear
collin lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch if startyear>1899
*	RESULT:  urbandum has high VIF (>10) due to presence of interaction variable urbxdeathtile10 
* Rerun without the interaction term urbxdeathtile10
collin lnparticnum urbandum deathtile10  democrat antimonarch if startyear>1899
*	RESULT:  all variables within acceptable range

* ++++++++++++++++++++++++++++++++++
* Visual inspection of potential outliers
* ++++++++++++++++++++++++++++++++++
*  Create predictions
use revolutionaryepsmiopp.dta, clear
quietly: logit success lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch if startyear>1899 , or nolog
predict pr , pr
predict stdres, rstand
predict dev, dev
predict hat, hat
predict dx2, dx2
predict dd, dd
* Standardized Pearson residuals by predicted probability
scatter stdres pr, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_2_scat1.pdf, replace
* 	RESULT: revid 359 (Tunisian independence movement) as potential outlier
*			revid 278 (Niger Constitutional Crisis) as potential outlier
*			revid 172 (Djiboutian Uprising 2011) as potential outlier
* Standardized Pearson residuals by revid
scatter stdres revid, mlab(revi)  yline(0) 
graph export Robustnesstestfiles\Logfiles\robch4tab4_2_scat2.pdf, replace
* 	RESULT: Identified revid 359 (Tunisian independence movement) as potential outlier
*			revid 145 (Azerbaijan color revolution attempt) as potential outlier 
*			revid 172 (Djiboutian Uprising 2011) as potential outlier
*			revid 106 (Solidarity Uprising) as potential outlier
*			revid 278 (Niger Constitutional Crisis) as potential outlier
*			revid 15 (Irish War of Independence) as potential outlier
*			revid 100 (Saur [April] Revolution) as potential outlier
* Deviance residual by revid
scatter dev revid, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_2_scat3.pdf, replace
* 	RESULT: revid 15 (Irish War of Independence) as potential outlier
*			revid 100 (Saur Revolution) as potential outlier
* Leverage by predicted probability
scatter hat pr, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_2_scat4.pdf, replace
* 	RESULT: not readable
* Leverage by revid (with cutoff point of 3 * the mean of leverage)
mean hat
matrix coefs = e(b)
local hatmean = 3 * (coefs[1,1])
scatter hat revid, mlab(revid) yline(0) yline(`hatmean')
graph export Robustnesstestfiles\Logfiles\robch4tab4_2_scat5.pdf, replace
* 	RESULT: not readable
* Difference of chi-squares
scatter dx2 revid, mlab(revid)
graph export Robustnesstestfiles\Logfiles\robch4tab4_2_scat6.pdf, replace
*	RESULT:  revid 359 (Tunisian independence movement) as potential outlier
*			 revid 15 (Irish War of Independence) as potential outlier
*			 revid 100 (Saur Revolution) as potential outlier
* Difference of deviances
scatter dd revid, mlab(revid)
graph export Robustnesstestfiles\Logfiles\robch4tab4_2_scat7.pdf, replace
*	RESULT: revid 15 (Irish War of Independence) as potential outlier 
*		 	revid 100 (Saur Revolution) as potential outlier
*		 	revid 278 (Niger Constitutional Crisis) as potential outlier
*		 	revid 172 (Djiboutian Uprising 2011) as potential outlier
*		 	revid 145 (Azerbaijan color revolution attempt) as potential outlier
*		 	revid 155 (Moldovan Twitter Revolution) as potential outlier
* Drop predictions
drop pr stdres dev hat dx2 dd

* Checking to see if dropping potential outliers alters any findings 
eststo: logit success lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch if startyear>1899 , or nolog
eststo: logit success lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch if startyear>1899 & revid~=15 & revid~=100 & revid~=106 & revid~=145 & revid~=155 & revid~=172 & revid~=278 & revid~=359, or nolog
esttab , star (+ 0.10 * 0.05 ** 0.01 *** 0.001) mtitles(All_n No_outl)
* 	RESULT:  antimonarch becomes marginally significant, but otherwise no changes in signs or patterns of statistical significance
eststo clear

* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Visual inspection of potential outliers, multiple imputation model
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
quietly: mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch if startyear>1899
mi predict xb using miest , xb
mi predict stdp using miest, stdp
scatter  stdp xb, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_2_scat8.pdf, replace
*	RESULT: revid 19 (Aster Revolution) as potential outlier
*			revid 337 (Argentinian Revolution of 1905) as potential outlier
*			revid 250 (1926 Indonesian Communist Revolt) as potential outlier
*			revid 61 (La Violencia) as potential outlier
*			revid 364 (Tupamaros) as potential outlier
*			revid 389 (Ar-Rashid Revolt) as potential outlier
*			revid 305 (Vaccine Revolt) as potential outlier
scatter  stdp revid, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_2_scat9.pdf, replace
*	RESULT: revid 19 (Aster Revolution) as potential outlier
*			revid 337 (Argentinian Revolution of 1905) as potential outlier
*			revid 250 (1926 Indonesian Communist Revolt) as potential outlier
*			revid 61 (La Violencia) as potential outlier
*			revid 364 (Tupamaros) as potential outlier
*			revid 389 (Ar-Rashid Revolt) as potential outlier
*			revid 305 (Vaccine Revolt) as potential outlier
* Drop predictions
drop xb stdp
* Testing the effect of dropping potential outliers on results in Model 6
eststo: quietly: mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch if startyear>1899 , or 
eststo: quietly: mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch if startyear>1899 & revid~=19 & revid~=61 & revid~=250 & revid~=305 & revid~=337 & revid~=364 & revid~=389, or
esttab , star (+ 0.10 * 0.05 ** 0.01 *** 0.001) mtitles(All_n No_outl) 
* 	RESULT:  No changes in signs and patterns of significance
eststo clear

* ++++++++++++++++++++++++++++++++++
* Linktest for omitted variable bias
* ++++++++++++++++++++++++++++++++++
quietly: logit success lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch if startyear>1899, or nolog
linktest , nolog
* 	RESULT:  passes, _hatsq is not statistically significant


* =======================================================================
* Bivariate relationships between regime characteristics and opposition 
*	features in the combined model
* =======================================================================
* The purpose of these tests is to show how to combining the two models
*	has an artificiality to it, given the relationships between the
*	variables in the two models

clear
use revolutionaryepsmicomb.dta

* Polity scores
* Relationships with organizational forms 
logit coalitionleadership newpolitymin1 newpolitymin1sq if startyear>1899, or nolog
*	RESULT:  Marginally significant and negative
logit traditionalleadership newpolitymin1 newpolitymin1sq if startyear>1899, or nolog
*	RESULT:  Statistically significant and negative
* Relationship with goals 
logit democrat newpolitymin1 newpolitymin1sq if startyear>1899, or nolog
*	RESULT:  Marginally significant and negative
logit antimonarch newpolitymin1 newpolitymin1sq if startyear>1899, or nolog
*	RESULT:  Statistically significant
* Relationship with participation
reg lnparticnum newpolitymin1 newpolitymin1sq if startyear>1899, vce(robust)
*	RESULT:  Statistically significant
* Relationship with violence
reg deathtile10 newpolitymin1 newpolitymin1sq if startyear>1899, vce(robust)
*	RESULT:  No relationship
logit urbandum newpolitymin1 newpolitymin1sq if startyear>1899, or nolog
*	RESULT:  No relationship

* Years incumbent in power
* Relationship with organizational forms 
logit coalitionleadership newincumbpowerdur if startyear>1899, or nolog
*	RESULT:  Marginally significant and positive
logit traditionalleadership newincumbpowerdur if startyear>1899, or nolog
*	RESULT:  Statistcally significant and positive
* Relationship with goals
logit democrat newincumbpowerdur if startyear>1899, or nolog
*	RESULT:  Statistically significant and positive
logit antimonarch newincumbpowerdur if startyear>1899, or nolog
*	RESULT:  Statistically significant and positive
* Relationship with participation
reg lnparticnum newincumbpowerdur if startyear>1899, vce(robust)
*	RESULT:  Statistically significant and positive
* Relationship with violence
reg deathtile10 newincumbpowerdur if startyear>1899, vce(robust)
*	RESULT:  Marginally significant and negative
logit urbandum newincumbpowerdur if startyear>1899, or nolog
*	RESULT:  Statistically significant and positive

* GDP per capita
* Relationship with organizational forms
logit coalitionleadership newgdppcthl if startyear>1899, or nolog
*	RESULT:  Statistically significant and positive
logit traditionalleadership newgdppcthl if startyear>1899, or nolog
*	RESULT:  Not significant and negative
* Relationship with goals 
logit democrat newgdppcthl if startyear>1899, or nolog
*	RESULT:  Statistically significant and positive
logit antimonarch newgdppcthl if startyear>1899, or nolog
*	RESULT:  Not sigificant and negative
* Relationship with participation
reg lnparticnum newgdppcthl if startyear>1899, vce(robust) 
*	RESULT:  Statistically significant and positive
* Relationship with violence 
reg deathtile10 newgdppcthl if startyear>1899, vce(robust)
*	RESULT:  Statistically significant and negative
logit urbandum newgdppcthl if startyear>1899, or nolog
*	RESULT:  Statistically significant and positive

* Oil production
* Relationship with organizational forms
logit coalitionleadership newlnoill if startyear>1899, or nolog
*	RESULT:  Not significant and negative
logit traditionalleadership newlnoill if startyear>1899, or nolog
*	RESULT:  Not significant and positive
* Relationship with goals 
logit democrat newlnoill if startyear>1899, or nolog
*	RESULT:  Not significant and negative
logit antimonarch newlnoill if startyear>1899, or nolog
*	RESULT:  Not significant and negative
* Relationship with participation
reg lnparticnum newlnoill if startyear>1899, vce(robust) 
*	RESULT:  Statistically significant and positive
* Relationship with violence 
reg deathtile10 newlnoill if startyear>1899, vce(robust)
*	RESULT:  Not significant and positive
* Relationship with urban location of contention
logit urbandum newlnoill if startyear>1899, or nolog
*	RESULT:  Not significant and positive

* Military expenditures per soldier (deciles)
* Years incumbent in power
* Relationship with organizational forms
logit coalitionleadership newmilexpsold10tile if startyear>1899, or nolog
*	RESULT:  Statistically significant and positive
logit traditionalleadership newmilexpsold10tile if startyear>1899, or nolog
*	RESULT:  Not significant and negative
* Relationship with goals 
logit democrat newmilexpsold10tile if startyear>1899, or nolog
*	RESULT:  Statistically significant and positive
logit antimonarch newmilexpsold10tile if startyear>1899, or nolog
*	RESULT:  Statistically significant and negative
* Relationship with participation
reg lnparticnum newmilexpsold10tile if startyear>1899, vce(robust) 
*	RESULT:  Statistically significant and positive
* Relationship with violence 
reg deathtile10 newmilexpsold10tile if startyear>1899, vce(robust)
*	RESULT:  Statistically significant and negative
* Relationship with urban location of contention
logit urbandum newmilexpsold10tile if startyear>1899, or nolog
*	RESULT:  Statistically significant and positive


* ++++++++++++++++++++++++++++++++++++++++++++++++++++
* ROBUSTNESS TESTS FOR COMBINED MODEL (2)in Table 4.3
* ++++++++++++++++++++++++++++++++++++++++++++++++++++

* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Bootstrapped standard errors--complete case sample--combined model (2)
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
use revolutionaryepsmicomb.dta, clear
eststo: logit success lnparticnum urbandum deathtile10 urbxdeathtile10 newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile if startyear>1899, or nolog
eststo: logit success lnparticnum urbandum deathtile10 urbxdeathtile10 newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile if startyear>1899, or nolog vce(bootstrap, bca seed(1234) rep(1000))
estat bootstrap, all
esttab , star (+ 0.10 * 0.05 ** 0.01 *** 0.001) mtitles(Orig Boot)
*	RESULT:  no changes in signs or patterns of statistical significance
eststo clear

* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Bootstrapping multiple imputation estimation--combined model (2)
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* using 10 imputations, 100 bootstraps (30 imputations takes a very long time)
* WARNING:  This test can take up to 50 minutes to complete execution
use revolutionaryeps.dta
drop if colony==1
program define myboot, rclass
   mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 = success civilwar urbandum democrat antimonarch, add(10) rseed(1234) force
   mi estimate, eform: logit success lnparticnum urbandum deathtile10 urbxdeathtile10 newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile, or
   return scalar b_lnp = el(e(b_mi),1,1)
   return scalar b_urb = el(e(b_mi),1,2)
   return scalar b_d10 = el(e(b_mi),1,3)
   return scalar b_uxd = el(e(b_mi),1,4)
   return scalar b_npo1 = el(e(b_mi),1,5)
   return scalar b_npsq = el(e(b_mi),1,6)
   return scalar b_newi = el(e(b_mi),1,7)
   return scalar b_newg = el(e(b_mi),1,8)
   return scalar b_newo = el(e(b_mi),1,9)
   return scalar b_newm = el(e(b_mi),1,10)
   return scalar b_int  = el(e(b_mi),1,11)
end
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed lnparticnum urbandum deathtile10 urbxdeathtile10 newcivxmilexp newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile
set seed 1234
bootstrap b_lnparticnum=r(b_lnp) b_urbandum=r(b_urb) b_deathtile10=r(b_d10) b_urbxdeathtile10=r(b_uxd) b_newpolitymin1=r(b_npo1) b_newpolitymin1sq=r(b_npsq) b_newincumbpowerdur=r(b_newi) b_newgdppcthl=r(b_newg) b_newlnoill=r(b_newo) b_newmilexpsold10tile=r(b_newm) intercept=r(b_int), reps(100): myboot 
* Displaying exponentiated form
bootstrap, eform
clear programs
* Result: All variables statistically significant, with exception of deathtile10

* ++++++++++++++++++++++++++++++++++++++++
* Visual inspection of potential outliers
* ++++++++++++++++++++++++++++++++++++++++

* Complete case sample
use revolutionaryepsmicomb.dta, clear
*  Create predictions
quietly: logit success lnparticnum urbandum deathtile10 urbxdeathtile10 newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile if startyear>1899, or nolog
predict pr , pr
predict stdres, rstand
predict dev, dev
predict hat, hat
predict dx2, dx2
predict dd, dd
* Standardized Pearson residuals by predicted probability
scatter stdres pr, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_3_scat1.pdf, replace
*	The following are potential outliers:
* 		revid 269 (1990 Mongolian Revolution), revid 106 (Solidarity Uprising), revid 195 (Togo 1991 Revolution)
* Standardized Pearson residuals by revid
scatter stdres revid, mlab(revi)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_3_scat2.pdf, replace
*	The following are potential outliers:
* 		revid 35 (Albanian Uprising of 1924) and revid 106 (Solidarity Uprising)
* Deviance residual by revid
scatter dev revid, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_3_scat3.pdf, replace
*	The following are potential outliers:
* 		revid 35 (Albanian Uprising of 1924) and revid 106 (Solidarity Uprising)
* Leverage by predicted probability
scatter hat pr, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_3_scat4.pdf, replace
*	The following are potential outliers:
* 		revid 372 (Second Tuareg Rebellion in Mali) and revid 102 (Iranian Revolution)
* Leverage by revid (with cutoff point of 3 * the mean of leverage)
mean hat
matrix coefs = e(b)
local hatmean = 3 * (coefs[1,1])
scatter hat revid, mlab(revid) yline(0) yline(`hatmean')
graph export Robustnesstestfiles\Logfiles\robch4tab4_3_scat5.pdf, replace
*	The following are potential outliers:
* 		revid 372 (Second Tuareg Rebellion in Mali) and revid 102 (Iranian Revolution)
* Difference of chi-squares
scatter dx2 revid, mlab(revid)
graph export Robustnesstestfiles\Logfiles\robch4tab4_3_scat6.pdf, replace
*	The following are potential outliers:
*	revid 106 (Solidarity Uprising) and revid 35 (Albanian Uprising of 1924)
* Difference of deviances
scatter dd revid, mlab(revid)
graph export Robustnesstestfiles\Logfiles\robch4tab4_3_scat7.pdf, replace
*	The following are potential outliers:
*	revid 106 (Solidarity Uprising) and revid 35 (Albanian Uprising of 1924)
* Drop predictions
drop pr stdres dev hat dx2 dd
* Checking to see if dropping potential outliers alters any findings 
eststo: logit success lnparticnum urbandum deathtile10 urbxdeathtile10 newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile if startyear>1899, or nolog
eststo: logit success lnparticnum urbandum deathtile10 urbxdeathtile10 newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile if startyear>1899 & revid!=35 & revid~=106 & revid~=372 & revid~=102 & revid~=269 & revid~=195, or nolog
esttab , star (+ 0.10 * 0.05 ** 0.01 *** 0.001) mtitles(All_n No_outl)
* 	RESULT:  deathtile10 grows marginally significant at the .10 level; otherwise, nothing changes
eststo clear

* Multiple imputation sample
use revolutionaryepsmicomb.dta, clear
quietly: mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10 newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile if startyear>1899
mi predict xb using miest , xb
mi predict stdp using miest, stdp
scatter  stdp xb, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_3_scat8.pdf, replace
*	RESULT: revid 301 (228 Uprising) as potential outlier
*			revid 249 (El Salvador Revolution of 1944) as potential outlier
*			revid 184 (Haitian Revolution of 1946) as potential outlier
*			revid 51 (Guatemalan Revolution) as potential outlier
*			revid 6 (Young Turk Revolution) as potential outlier
scatter  stdp revid, mlab(revid)  yline(0)
graph export Robustnesstestfiles\Logfiles\robch4tab4_3_scat9.pdf, replace
*	RESULT: revid 301 (228 Uprising) as potential outlier
*			revid 249 (El Salvador Revolution of 1944) as potential outlier
*			revid 184 (Haitian Revolution of 1946) as potential outlier
*			revid 51 (Guatemalan Revolution) as potential outlier
*			revid 6 (Young Turk Revolution) as potential outlier
*			revid 407 (Sandino Rebellion) as potential outlier
*			reivd 403 (South Sudanese Civil War) as potential outlier
* Drop predictions
drop xb stdp
* Testing the effect of dropping potential outliers on results in Model 6
eststo: quietly: mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10 newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile if startyear>1899 , or 
eststo: quietly: mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10 newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile if startyear>1899 & revid~=301 & revid~=249 & revid~=184 & revid~=51 & revid~=6 & revid~=407 & revid~=401, or
esttab , star (+ 0.10 * 0.05 ** 0.01 *** 0.001) mtitles(All_n No_outl) 
* 	RESULT:  No changes in signs and patterns of significance
eststo clear

* ===========================================================================
* FURTHER TESTS FOR OMITTED VARIABLE BIAS 
*	using multiple imputation and complete-case samples:  
*		pop size, econ growth, youth bulges, rough terrain (for rural 
*		episodes only), yrs schooling, soldiers per 1000 pop, civil society 
*		index, private ownership of economy, state capacity
* ===========================================================================

***********************
* Population size, t-1
************************
* Multiple imputation, impact on regime-specific model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newincumbpowerdur newincumbage newgdppcthl newlnoill newmilexpsold10tile newcivxmilexp lnpop
tab _mi_miss
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) lnpop = success civilwar, add(40) rseed(1234) force dots
* Bivariate
mi estimate, post dots eform saving(miest, replace): logit success lnpop if startyear>1899
* 	RESULT:  Not significant
* By urban/rural
mi estimate, post dots eform saving(miest, replace): logit success i.urbandum##c.lnpop if startyear>1899
* 	RESULT:  Not significant
* Impact on regime-specific model
mi estimate, post dots eform saving(miest, replace): logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp lnpop if startyear>1899
*	RESULT:  Not significant

* Multiple imputation, impact on opposition-specific model
clear
use revolutionaryeps.dta
* generate urbxdeathtile10 = urbandum * deathtile10
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed lnparticnum deathtile10 urbxdeathtile10 lnpop
tab _mi_miss
mi impute chained (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) lnpop = success urbandum democrat antimonarch, add(30) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  democrat antimonarch lnpop if startyear>1899
* 	RESULT:  Not significant.

* Complete-case sample
clear
use revolutionaryeps.dta, clear
* Bivariate relationships
* Population size, t-1
logit success lnpop if startyear>1899 & colony==0, or nolog 
* 	RESULT:  Not significant
* Population size, by urban/rural
logit success i.urbandum##c.lnpop if startyear>1899 & colony==0, or nolog 
* 	RESULT:  Not significant
* Impact on regime-specific model
logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp lnpop if startyear>1899 & colony==0, or nolog 
* 	RESULT:  Not significant and changes no signs or patterns of significance
* Impact on opposition-specific model
logit success lnparticnum urbandum deathtile10 urbxdeathtile10  democrat antimonarch lnpop if startyear>1899, or nolog
* 	RESULT:  Not significant.


***********************
* Economic growth, t-1
***********************
* Multiple imputation, impact on regime-specific model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newincumbpowerdur newincumbage newgdppcthl newlnoill newmilexpsold10tile newcivxmilexp gdpgrow1yr 
tab _mi_miss
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) gdpgrow1yr = success civilwar, add(50) rseed(1234) force dots
* Bivariate
mi estimate, post dots eform saving(miest, replace): logit success gdpgrow1yr if startyear>1899
* 	RESULT:  Not significant
* By urban/rural
mi estimate, post dots eform saving(miest, replace): logit success i.urbandum##c.gdpgrow1yr if startyear>1899
* 	RESULT:  Not significant
* Impact on regime-specific model
mi estimate, post dots eform saving(miest, replace): logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp gdpgrow1yr if startyear>1899
*	RESULT:  Not significant

* Multiple imputation, impact on opposition-specific model
clear
use revolutionaryeps.dta
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed lnparticnum deathtile10 urbxdeathtile10 gdpgrow1yr 
tab _mi_miss
mi impute chained (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) gdpgrow1yr = success urbandum democrat antimonarch, add(50) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  democrat antimonarch gdpgrow1yr if startyear>1899
* 	RESULT:  Not significant

* Complete-case sample
clear
use revolutionaryeps.dta
* Bivariate relationships
* Economic growth, t-1
logit success gdpgrow1yr if startyear>1899 & colony==0, or nolog 
* 	RESULT:  Not significant
* Economic growth, by urban/rural
logit success i.urbandum##c.gdpgrow1yr if startyear>1899 & colony==0, or nolog 
* 	RESULT:  Not significant
* Impact on regime-specific model
logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp gdpgrow1yr if startyear>1899 & colony==0, or nolog 
* 	RESULT:  Not significant
* Impact on opposition-specific model
logit success lnparticnum urbandum deathtile10 urbxdeathtile10  democrat antimonarch gdpgrow1yr if startyear>1899, or nolog
* 	RESULT:  Not significant


************************
* Youth bulge (under 15)
************************
* Multiple imputation, impact on regime-specific model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newincumbpowerdur newincumbage newgdppcthl newlnoill newmilexpsold10tile newcivxmilexp percunder15 
tab _mi_miss
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) percunder15 = success civilwar, add(60) rseed(1234) force dots
* Bivariate
mi estimate, post dots eform saving(miest, replace): logit success percunder15 if startyear>1899
* 	RESULT:  Not significant
* By urban/rural
mi estimate, post dots eform saving(miest, replace): logit success i.urbandum##c.percunder15 if startyear>1899
* 	RESULT:  Not significant
* Impact on regime-specific model
mi estimate, post dots eform saving(miest, replace): logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp percunder15 if startyear>1899
*	RESULT:  Not significant

* Multiple imputation, impact on opposition-specific model
clear
use revolutionaryeps.dta
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed lnparticnum deathtile10 urbxdeathtile10 percunder15 
tab _mi_miss
mi impute chained (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) percunder15 = success urbandum democrat antimonarch, add(60) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  democrat antimonarch percunder15 if startyear>1899
* 	RESULT:  Statistically significant at the .05 level, urbandum grows insignificant, no changes in signs or other patterns of significance

* Multiple imputation, impact on combined reduced model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newgdppcthl newlnoill newincumbpowerdur newmilexpsold10tile newcivxmilexp lnparticnum deathtile10 urbxdeathtile10 percunder15
tab _mi_miss
* Impute
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) percunder15 = success civilwar urbandum democrat antimonarch, add(60) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile percunder15 if startyear>1899
* 	RESULT:  Not significant

* Complete-case sample
clear
use revolutionaryeps.dta
* Youth bulge (under 15)--cases severely reduced
* Bivariate relationships
logit success percunder15 if startyear>1899 & colony==0, or nolog 
* 	RESULT:  Not significant
* Youth bulge (under 15), by urban/rural
logit success i.urbandum##c.percunder15 if startyear>1899 & colony==0, or nolog 
* 	RESULT:  Marginally significant for rural revolutions
* Impact on regime-specific model
logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp percunder15 if startyear>1899 & colony==0, or nolog 
* 	RESULT:  Not significant
* Impact on opposition-specific model
logit success lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch percunder15 if startyear>1899, or nolog
* 	RESULT:  Significant, and all variables grow insignificant except lnparticnum 
* Impact on combined reduced model
logit success lnparticnum urbandum deathtile10 urbxdeathtile10 newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile percunder15 if startyear>1899 & colony==0, or nolog
*	RESULT:  Not significant


*****************************
* Youth bulge (aged 20 to 39)
*****************************
* Multiple imputation, impact on regime-specific model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile newcivxmilexp youthpercl 
tab _mi_miss
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) youthpercl = success civilwar, add(60) rseed(1234) force dots
* Bivariate
mi estimate, post dots eform saving(miest, replace): logit success youthpercl if startyear>1899
* 	RESULT:  Not significant
* By urban/rural
mi estimate, post dots eform saving(miest, replace): logit success i.urbandum##c.youthpercl if startyear>1899
* 	RESULT:  Not significant
* Impact on regime-specific model
mi estimate, post dots eform saving(miest, replace): logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp youthpercl if startyear>1899

* Impact on opposition-specific model
clear
use revolutionaryeps.dta
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed lnparticnum deathtile10 urbxdeathtile10 youthpercl 
tab _mi_miss
mi impute chained (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) youthpercl = success urbandum democrat antimonarch, add(50) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  democrat antimonarch youthpercl if startyear>1899
* 	RESULT:  Marginally significant at the .10 level

* Impact on combined reduced model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newgdppcthl newlnoill newincumbpowerdur newmilexpsold10tile newcivxmilexp lnparticnum deathtile10 urbxdeathtile10 youthpercl 
tab _mi_miss
* Impute
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) youthpercl = success civilwar urbandum democrat antimonarch, add(60) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile youthpercl if startyear>1899
* 	RESULT:  Not significant

* Complete-case sample
clear
use revolutionaryeps.dta
* Youth bulge (aged 20 to 39)--highly reduced sample
* Bivariate
logit success youthpercl if startyear>1899 & colony==0, or nolog 
* 	RESULT:  Not significant
* Youth bulge (aged 20 to 39), by urban/rural
logit success i.urbandum##c.youthpercl if startyear>1899 & colony==0, or nolog 
* 	RESULT:  Not significant
* Impact on regime-specific model
logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp youthpercl if startyear>1899 & colony==0, or nolog
* 	RESULT: Not significant
* Impact on opposition-specific model
logit success lnparticnum urbandum deathtile10 urbxdeathtile10  democrat antimonarch youthpercl if startyear>1899, or nolog
* 	RESULT:  Marginally significant, turns all variables grow insignificant except lnparticnum 
* Impact on combined reduced model
logit success lnparticnum urbandum deathtile10 urbxdeathtile10 newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile youthpercl if startyear>1899 & colony==0, or nolog
* 	RESULT: Not significant


********************
* Percent mountains
********************
* Multiple imputation, impact on regime-specific model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile newcivxmilexp lnmtnest 
tab _mi_miss
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) lnmtnest = success civilwar, add(40) rseed(1234) force dots
* Bivariate
mi estimate, post dots eform saving(miest, replace): logit success lnmtnest if startyear>1899
* 	RESULT:  Not significant
* By urban/rural
mi estimate, post dots eform saving(miest, replace): logit success i.urbandum##c.lnmtnest if startyear>1899
* 	RESULT:  Not significant
* Impact on regime-specific model
mi estimate, post dots eform saving(miest, replace): logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp lnmtnest if startyear>1899
*	RESULT:  Not significant

* Multiple imputation, impact on opposition-specific model
clear
use revolutionaryeps.dta
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed lnparticnum deathtile10 urbxdeathtile10 lnmtnest 
tab _mi_miss
mi impute chained (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) lnmtnest = success urbandum democrat antimonarch, add(30) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  democrat antimonarch lnmtnest if startyear>1899
* 	RESULT:  Not significant

* Complete-case sample
clear
use revolutionaryeps.dta
* Percent mountains
* Bivariate
logit success lnmtnest if startyear>1899 & colony==0, or nolog
* 	RESULT:  Not significant
* Percent mountains, by urban/rural
logit success i.urbandum##c.lnmtnest if startyear>1899 & colony==0, or nolog
* 	RESULT:  Not significant
* Impact on regime-specific model
logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp lnmtnest if startyear>1899 & colony==0, or nolog
* 	RESULT:  Not significant and changes no signs or patterns of significance
* Impact on opposition-specific model
logit success lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch lnmtnest if startyear>1899, or nolog
* 	RESULT:  Not significant 

*******************************
* Avg total years of schooling
*******************************
* Multiple imputation, impact on regime-specific model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile newcivxmilexp avgtotalyrsschool 
tab _mi_miss
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) avgtotalyrsschool = success civilwar, add(70) rseed(1234) force dots
* Bivariate
mi estimate, post dots eform saving(miest, replace): logit success avgtotalyrsschool if startyear>1899
* 	RESULT:  Not significant
* By urban/rural
mi estimate, post dots eform saving(miest, replace): logit success i.urbandum##c.avgtotalyrsschool if startyear>1899
* 	RESULT:  Not significant
* Impact on regime-specific model
mi estimate, post dots eform saving(miest, replace): logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp avgtotalyrsschool if startyear>1899
*	RESULT:  Not significant

* Multiple imputation, impact on opposition-specific model
clear
use revolutionaryeps.dta
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed lnparticnum deathtile10 urbxdeathtile10 avgtotalyrsschool 
tab _mi_miss
mi impute chained (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) avgtotalyrsschool = success urbandum democrat antimonarch, add(70) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  democrat antimonarch avgtotalyrsschool if startyear>1899
* 	RESULT:  Statistically significant at the .01 level, but negative (seems opposite of what one would expect theoretically--it should not reduce the chance of opposition victory)

* Multiple imputation, impact on combined reduced model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newgdppcthl newlnoill newincumbpowerdur newmilexpsold10tile newcivxmilexp lnparticnum deathtile10 urbxdeathtile10 avgtotalyrsschool 
tab _mi_miss
* Impute
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) avgtotalyrsschool = success civilwar urbandum democrat antimonarch, add(70) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile avgtotalyrsschool if startyear>1899
* 	RESULT:  Not significant

* Complete-case sample
clear
use revolutionaryeps.dta
* Avg total years of schooling--highly reduced sample
* Bivariate
logit success avgtotalyrsschool if startyear>1899 & colony==0, or nolog
* 	RESULT: Not significant
* Avg total years of schooling, by urban/rural
logit success i.urbandum##c.avgtotalyrsschool if startyear>1899 & colony==0, or nolog
* 	RESULT: Not significant
* Impact on regime-specific model
logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp avgtotalyrsschool if startyear>1899 & colony==0, or nolog
* 	RESULT: Not significant 
* Impact on opposition-specific model
logit success lnparticnum urbandum deathtile10 democrat antimonarch avgtotalyrsschool if startyear>1899, or nolog
* 	RESULT: Is statistically significant, but switches signs from negative to positive
* Impact on combined reduced model
logit success lnparticnum urbandum deathtile10 urbxdeathtile10 newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile avgtotalyrsschool if startyear>1899 & colony==0, or nolog
* 	RESULT: Not significant

*****************************************
* Military personnel per 1000 population
*****************************************
* Multiple imputation, impact on regime-specific model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile newcivxmilexp milper1000
tab _mi_miss
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) milper1000 = success civilwar, add(30) rseed(1234) force dots
* Bivariate
mi estimate, post dots eform saving(miest, replace): logit success milper1000 if startyear>1899
* 	RESULT:  Not significant
* By urban/rural
mi estimate, post dots eform saving(miest, replace): logit success i.urbandum##c.milper1000 if startyear>1899
* 	RESULT:  Not significant
* Impact on regime-specific model
mi estimate, post dots eform saving(miest, replace): logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp milper1000 if startyear>1899
*	RESULT:  Not significant

* Multiple imputation, impact on opposition-specific model
clear
use revolutionaryeps.dta
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed lnparticnum deathtile10 urbxdeathtile10 milper1000
tab _mi_miss
mi impute chained (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) milper1000 = success urbandum democrat antimonarch, add(30) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  democrat antimonarch milper1000 if startyear>1899
* 	RESULT:  Not significant

* Complete-case sample
clear
use revolutionaryeps.dta
* Military personnel per 1000 population
* Bivariate
logit success milper1000 if startyear>1899 & colony==0, or nolog
* 	RESULT: Not significant 
* Military personnel per 1000 population, by urban/rural
logit success i.urbandum##c.milper1000 if startyear>1899 & colony==0, or nolog
* 	RESULT: Not significant 
* Impact on regime-specific model
logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp milper1000 if startyear>1899 & colony==0, or nolog
* 	RESULT: Not significant 


****************************
* V-Dem civil society index
****************************
* Multiple imputation, impact on regime-specific model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile newcivxmilexp newvdcivsocmin1 
tab _mi_miss
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) newvdcivsocmin1 = success civilwar, add(30) rseed(1234) force dots
* Bivariate
mi estimate, post dots eform saving(miest, replace): logit success newvdcivsocmin1 if startyear>1899
* 	RESULT:  Significant at the .05 level, but negative (i.e., thicker civil society lowers probability of opposition victory?)  Does not make theoretical sense.
* By urban/rural
mi estimate, post dots eform saving(miest, replace): logit success i.urbandum##c.newvdcivsocmin1 if startyear>1899
* 	RESULT:  Not significant
* Impact on regime-specific model
mi estimate, post dots eform saving(miest, replace): logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp newvdcivsocmin1 if startyear>1899
*	RESULT:  Not significant

* Multiple imputation, impact on opposition-specific model
clear
use revolutionaryeps.dta
drop if colony==1
* generate urbxdeathtile10 = urbandum * deathtile10
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed lnparticnum deathtile10 urbxdeathtile10 newvdcivsocmin1 
tab _mi_miss
mi impute chained (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) newvdcivsocmin1 = success urbandum democrat antimonarch, add(20) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  democrat antimonarch newvdcivsocmin1 if startyear>1899
* 	RESULT:  Marginally significant at the .10 level, but negative (thicker civil society should aid revolutionaries, not hinder them)

* Complete-case sample
clear
use revolutionaryeps.dta
* V-Dem civil society index
* Bivariate
logit success newvdcivsocmin1 if startyear>1899 & colony==0, or nolog
* 	RESULT: Marginally significant at .05 level, but negative (by theory, should be positive, not negative--probably proxying for something else)
* V-Dem civil society index, by urban/rural
logit success i.urbandum##c.newvdcivsocmin1 if startyear>1899 & colony==0, or nolog
*	RESULT:  not significant
* Impact on opposition-specific model 
logit success lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch newvdcivsocmin1 if startyear>1899, or nolog
* 	RESULT: Not significant

 
******************************************
* Private ownership of the economy (V-Dem)
******************************************
* Multiple imputation, impact on regime-specific model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile newcivxmilexp newvdstateownmin1 
tab _mi_miss
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) newvdstateownmin1 = success civilwar, add(30) rseed(1234) force dots
* Bivariate
mi estimate, post dots eform saving(miest, replace): logit success newvdstateownmin1 if startyear>1899
* 	RESULT:  Not significant.
* By urban/rural
mi estimate, post dots eform saving(miest, replace): logit success i.urbandum##c.newvdstateownmin1 if startyear>1899
* 	RESULT:  Not significant
* Impact on regime-specific model
mi estimate, post dots eform saving(miest, replace): logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp newvdstateownmin1 if startyear>1899
*	RESULT:  Not significant.

* Impact on opposition-specific model
clear
use revolutionaryeps.dta
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed lnparticnum deathtile10 urbxdeathtile10 newvdstateownmin1 
tab _mi_miss
mi impute chained (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) newvdstateownmin1 = success urbandum democrat antimonarch, add(20) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  democrat antimonarch vdstateownmin1 if startyear>1899
* 	RESULT:  Not significant

* Complete-case sample
clear
use revolutionaryeps.dta
* Private ownership of the economy (V-Dem)
* Bivariate
logit success newvdstateownmin1 if startyear>1899 & colony==0, or nolog 
* 	RESULT: Not significant 
* Private ownership of the economy (V-Dem), by urban/rural
logit success i.urbandum##c.newvdstateownmin1 if startyear>1899 & colony==0, or nolog 
* 	RESULT: Not significant 
* Impact on regime-specific model
logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp newvdstateownmin1 if startyear>1899 & colony==0, or nolog
* 	RESULT: Not significant 
* Impact on opposition-specific model
logit success lnparticnum urbandum deathtile10 urbxdeathtile10 democrat antimonarch newvdstateownmin1 if startyear>1899, or nolog
* 	RESULT: Not significant 


***********************************
* V-Dem executive corruption index
***********************************
* Multiple imputation, impact on regime-specific model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile newcivxmilexp newv2x_execorr 
tab _mi_miss
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) newv2x_execorr = success civilwar, add(20) rseed(1234) force dots
* Bivariate
mi estimate, post dots eform saving(miest, replace): logit success newv2x_execorr if startyear>1899
* 	RESULT:  Significant at the .05 level.
* By urban/rural
mi estimate, post dots eform saving(miest, replace): logit success i.urbandum##c.newv2x_execorr if startyear>1899
* 	RESULT:  Not significant
* Impact on regime-specific model
mi estimate, post dots eform saving(miest, replace): logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp newv2x_execorr if startyear>1899
*	RESULT:  Not significant.

* Multiple imputation, impact on opposition-specific model
clear
use revolutionaryeps.dta
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed lnparticnum deathtile10 urbxdeathtile10 newv2x_execorr
tab _mi_miss
mi impute chained (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) newv2x_execorr = success urbandum democrat antimonarch, add(20) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  democrat antimonarch newv2x_execorr if startyear>1899
* 	RESULT:  Significant at the .05 level (though not clear how this fits theoretically into the opposition model)

* Multiple imputation, impact on combined reduced model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newgdppcthl newlnoill newincumbpowerdur newmilexpsold10tile newcivxmilexp lnparticnum deathtile10 urbxdeathtile10 newv2x_execorr
tab _mi_miss
* Impute
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) newv2x_execorr = success civilwar urbandum democrat antimonarch, add(30) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile newv2x_execorr if startyear>1899
* 	RESULT:  Not significant

* Complete-case sample
clear
use revolutionaryeps.dta
* V-Dem executive corruption index
* Bivariate
logit success v2x_execorr if startyear>1899 & colony==0, or nolog
* 	RESULT: Marginally significant at the .10 level
* Executive corruption, by urban/rural
logit success i.urbandum##c.v2x_execorr if startyear>1899 & colony==0, or nolog
* 	RESULT: No interaction
* Impact on regime-specific model
logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp vdstateownmin1 v2x_execorr if startyear>1899 & colony==0, or nolog
* 	RESULT: Not significant 


*************************************
* Sigman/Hanson state capacity index
*************************************
* Multiple imputation, impact on regime-specific model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile newcivxmilexp newstatecapacity
tab _mi_miss
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) newstatecapacity = success civilwar, add(60) rseed(1234) force dots
* Bivariate
mi estimate, post dots eform saving(miest, replace): logit success newstatecapacity if startyear>1899
* 	RESULT:  Not significant.
* By urban/rural
mi estimate, post dots eform saving(miest, replace): logit success i.urbandum##c.newstatecapacity if startyear>1899
* 	RESULT:  Marginally significant for rural revolutions, but not significant for urban
* Impact on regime-specific model
mi estimate, post dots eform saving(miest, replace): logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp newstatecapacity if startyear>1899
*	RESULT:  Significant at the .05 level.  Turns GDP per capita statistically insignificant

* Multiple imputation, impact on combined reduced model
clear
use revolutionaryeps.dta
drop if colony==1
mi set wide
mi xtset, clear
mi stset, clear
mi register imputed newpolitymin1 newpolitymin1sq newgdppcthl newlnoill newincumbpowerdur newmilexpsold10tile newcivxmilexp lnparticnum deathtile10 urbxdeathtile10 newstatecapacity
tab _mi_miss
* Impute
mi impute chained (pmm, knn(3)) newpolitymin1 newpolitymin1sq (truncreg, ll(0)) newgdppcthl (pmm, knn(3)) newlnoill (pmm, knn(3)) newincumbpowerdur (truncreg, ll(0) ul(10)) newmilexpsold10tile (pmm, knn(3)) newcivxmilexp (pmm, knn(3)) lnparticnum (truncreg, ll(0) ul(10)) deathtile10 (pmm, knn(3)) urbxdeathtile10 (pmm, knn(3)) newstatecapacity = success civilwar urbandum democrat antimonarch, add(60) rseed(1234) force dots
mi estimate, post dots eform saving(miest, replace): logit success lnparticnum urbandum deathtile10 urbxdeathtile10  newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile newstatecapacity if startyear>1899
* 	RESULT:  Statistically significant at the .05 level; turns GDP per capita insignificant

* Complete-case sample
clear
use revolutionaryeps.dta
* Sigman/Hanson state capacity index (sample significantly reduced)
* Bivariate
logit success newstatecapacity if startyear>1899 & colony==0, or nolog
* 	RESULT: Not significant 
* State capacity, by urban/rural
logit success i.urbandum##c.newstatecapacity if startyear>1899 & colony==0, or nolog
*	RESULT:  Significant at .05 level for rural revolutions, not significant for urban revolutions
* Impact on regime-specific model
logit success newpolitymin1 newpolitymin1sq newincumbpowerdur newgdppcthl newlnoill newmilexpsold10tile civilwar newcivxmilexp newstatecapacity if startyear>1899 & colony==0, or nolog
* 	RESULT: Not significant 


log close

erase miest.ster

clear
